package Vista;

import Control.Control;
import Control.ControlGestores;
import Modelo.Grupo;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

/**
 *
 * @author Araya
 */
public class HorarioAlternoConsultar extends JPanel {

    private Control control;
    public JButton jButton1 = new JButton();
    //public JButton jButton2 = new JButton();
    public JButton jButton3 = new JButton();
    public JButton jButton4 = new JButton();
    //public JButton jButton5 = new JButton();
    public JLabel jLabel1 = new JLabel();
    public JTabbedPane principal = new JTabbedPane();
    public JTabbedPane setimo = new JTabbedPane();
    public JTabbedPane octavo = new JTabbedPane();
    public JTabbedPane noveno = new JTabbedPane();
    public JTabbedPane decimo = new JTabbedPane();
    public JTabbedPane undecimo = new JTabbedPane();
    public ControlGestores cg = new ControlGestores();

    public HorarioAlternoConsultar(Control pControl) {
        control = pControl;
        initComponentes();
    }

    private void initComponentes() {
        JScrollPane jsp = new JScrollPane();
        JPanel p1 = new JPanel();
        p1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        p1.setBackground(new java.awt.Color(255, 255, 255));
        ArrayList<Grupo> listSetimo = cg.getGestorGrupo().obtenerSeccion("7");
        ArrayList<Grupo> listOctavo = cg.getGestorGrupo().obtenerSeccion("8");
        ArrayList<Grupo> listNoveno = cg.getGestorGrupo().obtenerSeccion("9");
        ArrayList<Grupo> listDecimo = cg.getGestorGrupo().obtenerSeccion("10");
        ArrayList<Grupo> listUndecimo = cg.getGestorGrupo().obtenerSeccion("11");

        ArrayList<String> setimosOrd = new ArrayList();
        ArrayList<String> octavosOrd = new ArrayList();
        ArrayList<String> novenosOrd = new ArrayList();
        ArrayList<String> decimosOrd = new ArrayList();
        ArrayList<String> undecimosOrd = new ArrayList();

        for (Grupo g : listSetimo) {
            if (g.getSeccion().length() == 3) {
                setimosOrd.add(g.getSeccion());
            }
        }
        for (Grupo g : listSetimo) {
            if (g.getSeccion().length() == 4) {
                setimosOrd.add(g.getSeccion());
            }
        }

        for (Grupo g : listOctavo) {
            if (g.getSeccion().length() == 3) {
                octavosOrd.add(g.getSeccion());
            }
        }
        for (Grupo g : listOctavo) {
            if (g.getSeccion().length() == 4) {
                octavosOrd.add(g.getSeccion());
            }
        }

        for (Grupo g : listNoveno) {
            if (g.getSeccion().length() == 3) {
                novenosOrd.add(g.getSeccion());
            }
        }
        for (Grupo g : listNoveno) {
            if (g.getSeccion().length() == 4) {
                novenosOrd.add(g.getSeccion());
            }
        }

        for (Grupo g : listDecimo) {
            if (g.getSeccion().length() == 4) {
                decimosOrd.add(g.getSeccion());
            }
        }
        for (Grupo g : listDecimo) {
            if (g.getSeccion().length() == 5) {
                decimosOrd.add(g.getSeccion());
            }
        }

        for (Grupo g : listUndecimo) {
            if (g.getSeccion().length() == 4) {
                undecimosOrd.add(g.getSeccion());
            }
        }
        for (Grupo g : listUndecimo) {
            if (g.getSeccion().length() == 5) {
                undecimosOrd.add(g.getSeccion());
            }
        }

        if (!setimosOrd.isEmpty()) {
            for (int i = 0; i < setimosOrd.size(); i++) {
                setimo.add(new HorarioAlternoConsultar1(control));
                setimo.setTitleAt(i, setimosOrd.get(i));
            }
        }
        if (!octavosOrd.isEmpty()) {
            for (int i = 0; i < octavosOrd.size(); i++) {
                octavo.add(new HorarioAlternoConsultar1(control));
                octavo.setTitleAt(i, octavosOrd.get(i));
            }
        }
        if (!novenosOrd.isEmpty()) {
            for (int i = 0; i < novenosOrd.size(); i++) {
                noveno.add(new HorarioAlternoConsultar1(control));
                noveno.setTitleAt(i, novenosOrd.get(i));
            }
        }
        if (decimosOrd != null) {
            for (int i = 0; i < decimosOrd.size(); i++) {
                decimo.add(new HorarioAlternoConsultar1(control));
                decimo.setTitleAt(i, decimosOrd.get(i));
            }
        }
        if (undecimosOrd != null) {
            for (int i = 0; i < undecimosOrd.size(); i++) {
                undecimo.add(new HorarioAlternoConsultar1(control));
                undecimo.setTitleAt(i, undecimosOrd.get(i));
            }
        }
        principal.addTab("Nivel 7°", setimo);
        principal.addTab("Nivel 8°", octavo);
        principal.addTab("Nivel 9°", noveno);
        principal.addTab("Nivel 10°", decimo);
        principal.addTab("Nivel 11°", undecimo);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/Regresar.png"))); // NOI18N
        jButton1.setBorder(null);
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/RegresarPressed.png"))); // NOI18N
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/RegresarHover.png"))); // NOI18N

//        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/Guardar.png"))); // NOI18N
//        jButton2.setBorder(null);
//        jButton2.setBorderPainted(false);
//        jButton2.setContentAreaFilled(false);
//        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
//        jButton2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GuardarPressed.png"))); // NOI18N
//        jButton2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GuardarHover.png"))); // NOI18N

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GenerarReporte.png"))); // NOI18N
        jButton3.setBorder(null);
        jButton3.setBorderPainted(false);
        jButton3.setContentAreaFilled(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GenerarReportePressed.png"))); // NOI18N
        jButton3.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GenerarReporteHover.png"))); // NOI18N

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GenerarReporteActual.png"))); // NOI18N
        jButton4.setBorder(null);
        jButton4.setBorderPainted(false);
        jButton4.setContentAreaFilled(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GenerarReporteActualPressed.png"))); // NOI18N
        jButton4.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/GenerarReporteActualHover.png"))); // NOI18N

//        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/Modificar.png"))); // NOI18N
//        jButton5.setBorder(null);
//        jButton5.setBorderPainted(false);
//        jButton5.setContentAreaFilled(false);
//        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
//        jButton5.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/ModificarPressed.png"))); // NOI18N
//        jButton5.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/imgs/ModificarHover.png"))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N
        jLabel1.setText("Consulta de horario");
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        p1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints((int) (d.getWidth() / 2) - 100, 40, 240, -1));
        p1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, -1, -1));
        //p1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(1220, 650, -1, -1));
        p1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(1210, 500, -1, -1));
        p1.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(1210, 550, -1, -1));
       // p1.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(1220, 600, -1, -1));
        p1.add(principal, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 85, -1, -1));
        jsp.add(p1);
        add(p1);
    }

    public Control getControl() {
        return control;
    }

    public void setControl(Control control) {
        this.control = control;
    }

    public JTabbedPane obtenerPanel(String panelActual) {
        if (panelActual.equals("setimo")) {
            return this.setimo;
        }
        if (panelActual.equals("octavo")) {
            return this.octavo;
        }
        if (panelActual.equals("noveno")) {
            return this.noveno;
        }
        if (panelActual.equals("decimo")) {
            return this.decimo;
        }
        if (panelActual.equals("undecimo")) {
            return this.undecimo;
        }
        return null;

    }

}
